cmake_minimum_required(VERSION 3.15)

project(wayland-clipboard)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(PkgConfig REQUIRED)

pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols)
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)

find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)

add_custom_command(
    OUTPUT ${CMAKE_SOURCE_DIR}/build/wlr-data-control-unstable-v1.h
    COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header ${CMAKE_SOURCE_DIR}/wlr-data-control-unstable-v1.xml ${CMAKE_SOURCE_DIR}/build/wlr-data-control-unstable-v1.h
    DEPENDS ${CMAKE_SOURCE_DIR}/wlr-data-control-unstable-v1.xml
)

add_custom_command(
    OUTPUT ${CMAKE_SOURCE_DIR}/build/wlr-data-control-unstable-v1.c
    COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code ${CMAKE_SOURCE_DIR}/wlr-data-control-unstable-v1.xml ${CMAKE_SOURCE_DIR}/build/wlr-data-control-unstable-v1.c
    DEPENDS ${CMAKE_SOURCE_DIR}/wlr-data-control-unstable-v1.xml
)

include_directories(${CMAKE_SOURCE_DIR}/build)

add_executable(wayland-clipboard-manager main.cpp ${CMAKE_SOURCE_DIR}/build/wlr-data-control-unstable-v1.c ${CMAKE_SOURCE_DIR}/build/wlr-data-control-unstable-v1.h)

target_link_libraries(wayland-clipboard-manager wayland-client)